<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>10-localStorage</title>
</head>
<body>


<button onclick="fn1()">设置localStorage</button>
<button onclick="fn2()">获取localStorage</button>
<button onclick="fn3()">清空localStorage</button>

</body>
<script>

    /**
     * 设置sessionStorage
     */
    function fn1() {
        localStorage.setItem("msg2","helloworld");
    }

    /**
     * 获取sessionStorage
     */
    function fn2() {
        var msg = localStorage.getItem("msg2");
        console.log("msg2 = " + msg)
    }

    /**
     * 清空sessionStorage
     */
    function fn3() {
        localStorage.removeItem("msg2");
    }

</script>
</html>